﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using Models;
using System.Data.SqlClient;

namespace BLL
{
    public class CollectManager
    {
        CollectService service = new CollectService();
        public bool add(Collect collect)
        {
            //新增功能
            return service.add(collect);
        }
        //根据id查询
        public List<Collect> get(int id)
        {
            List<Collect> coll = new List<Collect>();
            SqlDataReader reader = service.get(id);
            while (reader.Read())
            {
                coll.Add(new Collect(
                    reader.GetInt32(0),
                    reader.GetInt32(1),
                    reader.GetInt32(2),
                    reader.GetInt32(3)
                    ));
            }
            DBhelper.Close();
            return coll;
        }
        //public List<Product> GetList2(int id)
        //{
        //    List<Product> coll = new List<Product>();
        //    SqlDataReader reader = service.getby(id);
        //    while (reader.Read())
        //    {
        //        coll.Add(new Product(
        //            reader.GetDecimal(0),
        //            reader.GetString(1),
        //            reader.GetString(2)
        //            ));
        //    }
        //    DBhelper.Close();
        //    return coll;
        //}
    }
}
